package com.example.mbl.controller;

import com.example.mbl.entity.Patent;
import com.example.mbl.interceptor.AppToken;
import com.example.mbl.result.PageResult;
import com.example.mbl.result.WebRestResult;
import com.example.mbl.result.business.PatentPageResult;
import com.example.mbl.service.PatentService;
import javafx.geometry.Pos;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("Patent")
public class PatentController {
    @Autowired
    private PatentService patentService;

    @AppToken
    @PostMapping("addPatent")
    public WebRestResult addPatent(@RequestBody Patent patent){
        WebRestResult result = patentService.addPatent(patent);
        return result;
    }

    @AppToken
    @PostMapping("deletePatent")
    public WebRestResult deletePatent(@RequestBody Patent patent){
        WebRestResult result = patentService.deletePatent(patent);
        return result;
    }

    @AppToken
    @PostMapping("updatePatent")
    public WebRestResult updatePatent(@RequestBody Patent patent){
        WebRestResult result = patentService.updatePatent(patent);
        return result;
    }

    @GetMapping("getPatentList")
    public PageResult<PatentPageResult> getPatentList(String year, int page, int pagesize){
        PageResult<PatentPageResult> result = patentService.getPatentList(year,page,pagesize);
        return result;
    }
}
